/*
 * This file is part of the Gwt-Generator project and was written by Raphael Brugier <raphael dot brugier at gmail dot com > for Objet Direct
 * <http://wwww.objetdirect.com>
 * 
 * Copyright c 2010 Objet Direct
 * 
 * Gwt-Generator is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * Gwt-Generator is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with Gwt-Generator. If not, see <http://www.gnu.org/licenses/>.
 */
package com.objetdirect.gwt.gen.shared.dto;

import java.io.Serializable;

import com.objetdirect.gwt.umlapi.client.umlCanvas.UMLCanvas;
import com.objetdirect.gwt.umlapi.client.umlcomponents.DiagramType;

/**
 * Data Transfert Object for the diagram entity.
 * @author Raphael Brugier (raphael-dot-brugier.at.gmail'dot'com)
 */
@SuppressWarnings("serial")
public class DiagramDto implements Serializable {
	
	private String key;
	
	private String name;
	
	private DiagramType type;
	
	private String directoryKey;
	
	private UMLCanvas canvas;
	
	private boolean isSeamDiagram;

	private boolean isEditable;
	
	/**
	 * In the case where the diagram is an object diagram, this is the key to the Class diagram that it instantiates. 
	 */
	public String classDiagramKey;
	
	
	/** Default constructor. */
	public DiagramDto() {}
	
	
	/**
	 * Use this constructor to create a new diagram.
	 * @param directoryKey The key of the owner directory
	 * @param name the name of the diagram
	 * @param type the type of the diagram
	 */
	public DiagramDto(String directoryKey, String name, DiagramType type) {
		this.name = name;
		this.type = type;
		this.directoryKey = directoryKey;
		isEditable = true;
		isSeamDiagram = false;
	}
	
	/**
	 * This constructor should only been used from diagramService after retrieving a diagram from the base.
	 * @param key the key of the diagram. Autogenerated by GAE.
	 * @param directoryKey The key of the owner directory
	 * @param name the name of the diagram
	 * @param type the type of the diagram
	 */
	public DiagramDto(String key, String directoryKey, String name, DiagramType type) {
		this(directoryKey, name, type);
		this.key = key;
	}

	/**
	 * This constructor should only been used from diagramService after retrieving a diagram from the base.
	 * @param key the key of the diagram. Autogenerated by GAE.
	 * @param directoryKey The key of the owner directory
	 * @param name the name of the diagram
	 * @param type the type of the diagram
	 */
	public DiagramDto(String key, String directoryKey, String name, DiagramType type, UMLCanvas umlCanvas) {
		this(key, directoryKey, name, type);
		this.canvas = umlCanvas;
	}

	/**
	 * @return the key
	 */
	public String getKey() {
		return key;
	}


	/**
	 * @param key the key to set
	 */
	public void setKey(String key) {
		this.key = key;
	}


	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}


	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}


	/**
	 * @return the type
	 */
	public DiagramType getType() {
		return type;
	}


	/**
	 * @param type the type to set
	 */
	public void setType(DiagramType type) {
		this.type = type;
	}


	/**
	 * @return the canvas
	 */
	public UMLCanvas getCanvas() {
		return canvas;
	}


	/**
	 * @param canvas the canvas to set
	 */
	public void setCanvas(UMLCanvas canvas) {
		this.canvas = canvas;
	}


	/**
	 * @return the directoryKey
	 */
	public String getDirectoryKey() {
		return directoryKey;
	}


	/**
	 * @param directoryKey the directoryKey to set
	 */
	public void setDirectoryKey(String directoryKey) {
		this.directoryKey = directoryKey;
	}
	
	/**
	 * @return the isSseamDiagram
	 */
	public boolean isSeamDiagram() {
		return isSeamDiagram;
	}


	/**
	 * @param isSeamDiagram the isSseamDiagram to set
	 */
	public void setIsSeamDiagram(boolean isSeamDiagram) {
		this.isSeamDiagram = isSeamDiagram;
	}
	
	/**
	 * @return the isEditable
	 */
	public boolean isEditable() {
		return isEditable;
	}


	/**
	 * @param isEditable the isEditable to set
	 */
	public void setEditable(boolean isEditable) {
		this.isEditable = isEditable;
	}
	
	@Override
	public String toString() {
		return "DiagramDto [canvas=" + canvas + ", classDiagramKey=" + classDiagramKey + ", directoryKey=" + directoryKey + ", isEditable=" + isEditable
				+ ", isSeamDiagram=" + isSeamDiagram + ", key=" + key + ", name=" + name + ", type=" + type + "]";
	}
}
